import { GetAvailableRoomsConfig } from "../../GOBE/GOBE";
import { SceneType } from "../CommonValue";
import GameUtils from "../GameUtils";
import { Global } from "../Global";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Hall extends cc.Component {
    @property(cc.Label)
    roomList: cc.Label = null;

    private roomInfos = [];
    private getAvailableRoomsConfig: GetAvailableRoomsConfig = null;
    protected start(): void {
        this.getAvailableRoomsConfig = {
            roomType: "1",              // 房间类型
            offset: '0',                  // 偏移量
            limit: 30,                    // 单次请求获取的房间数量
            sync: false,                   // 是否返回帧同步中的房间
            roomTypeList: ['蓝队', '红队'], // 房间类型列表
        };
    }


    protected update(dt: number): void {

        // Global.Inst().client.getAvailableRooms(this.getAvailableRoomsConfig).then((infos) => {
        //     // 查询房间列表成功
        //     this.roomInfos = infos.rooms;
        //     // 记录下次查询房间的偏移量
        //     this.getAvailableRoomsConfig.offset = infos.offset;
        //     let roomsCode = "";
        //     for (let index = 0; index < this.roomInfos.length; index++) {
        //         const element = this.roomInfos[index];
        //         roomsCode += element.roomCode

        //     }
        //     this.roomList.string = roomsCode;

        // }).catch((e) => {
        //     // 查询房间列表失败
        //     this.roomInfos = [];
        // });
    }

    /**
     * “普通房间”按钮点击事件
     */
    OnOrdinaryRoomBtn() {
        GameUtils.Log(`正在进入菜鸟区`);
        Global.Inst().matchRule = '1';
        cc.director.loadScene(SceneType.MATCH);
    }

    /**
     * “高手房间”按钮点击事件
     */
    OnExpertRoomBtn() {
        GameUtils.Log(`正在进入高手区`);
        Global.Inst().matchRule = '2';
        cc.director.loadScene(SceneType.MATCH);
    }


}
